package cn.itsource.hrm.web.controller;

import cn.itsource.hrm.service.IVerifyCodeService;
import cn.itsource.hrm.util.AjaxResult;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.Map;

@RequestMapping("/verifycode")
@RestController
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService ;

    //获取图片验证码 , 返回base64字符串
    @PostMapping("/sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody Map<String,String> map){
        try {
            //return verifyCodeService.createImageCode(imageCodeKey);
            return AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage("发送失败了");
        }
    }
    //获取图片验证码 , 返回base64字符串
    @PostMapping("/imageCode/{imageCodeKey}")
    public String imageCode(@PathVariable("imageCodeKey")String imageCodeKey){
        try {
            return verifyCodeService.createImageCode(imageCodeKey);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}
